import React, { Component } from 'react';
import {View, ScrollView} from 'react-native'
import ClassStaticsItem from './class_statics_item'
import {GetClassroomReports} from '../../config/api'
import Loading from '../common/loading_common'
import styles,{BLUE} from '../../config/styles'

class ClassStaticsIndex extends Component {
    state = {
        staticsModels: [],
        loading: true
    }

    componentDidMount () {
        GetClassroomReports().then((data)=>{
            if(data.code==0){
                this.setState({
                    staticsModels:data.data,
                    loading: false
                })
            }
        })
    }

    render () {
        const {loading, staticsModels} = this.state;
        if (loading == true) {
            return <Loading />
        } else {
            return(
                <ScrollView tabLabel='班级统计' style={[styles.main_body]}>
                {
                    staticsModels.map((classStatic,index) => {
                        return <ClassStaticsItem  pointerEvents="none" classStatic = {classStatic} key={index}/>
                    })
                }
                </ScrollView>
            )
        }

      
    }
}

export default ClassStaticsIndex

